import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:xihuwenti_tickets/ui/select_site_page.dart';

import 'package:xihuwenti_tickets/ui/select_venue_page.dart';

void main() {
  setupLocator();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final routes = {
    '/detail': (context, {arguments}) => SelectSitePage(
          arguments: arguments,
        )
  };

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(builder: (context, cons) {
      HttpGo.HttpGogetInstance();
      if (BuildConfig.isDebug) {
        // HttpGo.instance.setProxy("192.168.3.61", 8888, true);
      }
      ScreenHelper.initHelper(cons);
      return MaterialApp(
        initialRoute: '/',
        onGenerateRoute: (RouteSettings settings) {
          final String name = settings.name;
          final Function pageContentBuilder = routes[name];
          if (pageContentBuilder != null) {
            if (settings.arguments != null) {
              final Route route = MaterialPageRoute(
                  builder: (context) => pageContentBuilder(context,
                      arguments: settings.arguments));
              return route;
            } else {
              final Route route = MaterialPageRoute(
                  builder: (context) => pageContentBuilder(context));
              return route;
            }
          } else {
            return null;
          }
        },
        title: '冲冲冲',
        navigatorKey: NavigateService.getInstance().key,
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: SelectVenuePage(),
      );
    });
  }
}
